import request from '@/utils/request';
import { DeviceMaintenanceVO, DeviceMaintenanceQuery } from './types';

export interface DeviceMaintenanceData {
  id: number;
  deviceId: number;
  maintenanceType: string;
  maintenanceTime: string;
  maintenancePerson: string;
  maintenanceContent: string;
  maintenanceResult: string;
  remark: string;
  createTime: string;
  updateTime: string;
}

// 查询设备维护列表
export const getDeviceMaintenanceList = (params: DeviceMaintenanceQuery) => {
  return request({
    url: '/vending/maintenance/list',
    method: 'get',
    params
  });
};

// 获取设备维护详细信息
export const getDeviceMaintenance = (id: number) => {
  return request({
    url: `/vending/maintenance/${id}`,
    method: 'get'
  });
};

// 新增设备维护
export const addDeviceMaintenance = (data: DeviceMaintenanceVO) => {
  return request({
    url: '/vending/maintenance',
    method: 'post',
    data
  });
};

// 修改设备维护
export const updateDeviceMaintenance = (data: DeviceMaintenanceVO) => {
  return request({
    url: '/vending/maintenance',
    method: 'put',
    data
  });
};

// 删除设备维护
export const deleteDeviceMaintenance = (id: number) => {
  return request({
    url: `/vending/maintenance/${id}`,
    method: 'delete'
  });
};

// 批量删除设备维护
export const deleteDeviceMaintenanceBatch = (ids: number[]) => {
  return request({
    url: `/vending/maintenance/batch/${ids.join(',')}`,
    method: 'delete'
  });
};
